<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        * {
            margin: 0;
            padding: 0
        }

        canvas {
            border: 2px solid #a4e2f9;
            margin: 30px auto;
            display: block;
            color: aliceblue;
        }
    </style>
</head>

<body>

    <canvas height="300" width="500" id="myCanvas"></canvas>
</body>

</html>
<script>
    var c = document.getElementById("myCanvas");
    var ctx = c.getContext("2d");

    //绘制心形
    ctx.beginPath();
    ctx.moveTo(100, 130);
    ctx.bezierCurveTo(100, 50, 170, 50, 200, 100);
    ctx.bezierCurveTo(230, 50, 300, 50, 300, 130);
    ctx.bezierCurveTo(300, 140, 300, 210, 200, 250);
    ctx.bezierCurveTo(100, 200, 100, 140, 100, 130);
    ctx.stroke();
    
</script>